<template>
  <div id="assessdetail">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/assess' }">干部考核</el-breadcrumb-item>
      <el-breadcrumb-item>项目起草</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row>
      <el-col :style="'background:#fff;margin:0 10px; padding:0;height:'+tableHeight+'px;overflow: hidden;'" class="assessdetail">
              <el-scrollbar style="height: calc(100% + 17px);">
                <editbaseinfo :myid='this.$route.params.id'></editbaseinfo>
              </el-scrollbar>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import editbaseinfo from '@/assess/Editbaseinfo.vue'
import leaderticket from '@/components/VoteTemp1.vue'
import leaderticketdetail from '@/components/VoteDetailTemp.vue'
export default {
  components: {
    leaderticket,
    editbaseinfo,
    leaderticketdetail
  },
  data () {
    return {
      leaders: [],
      leaderszhengzhi: [],
      preferments: [],
      unitpoint: [1, 2, 3, 4, 5, 6],
      leaderpoint: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
      showdata: false,
      fileList: [],
      resultActiveName: 'ticket',
      ticketid: 0,
      leaderTicketVisible: false,
      leaderTicketDetailVisible: false,
      ticketLeaderList: [],
      ticketLeaderListLoading: false,
      activeName: 'zhunbei',
      unitcode: '',
      unitname: '',
      ticketinfoshow: false,
      kaohe: {},
      pingyi: {},
      tabledata: {'ZUOFEI': ['', '', '', ''], 'ALL': ['', '', '', ''], 'YITOU': ['', '', '', ''], 'SHENGYU': ['', '', '', ''], 'WEITOU': ['', '', '', '']},
      tableHeight: 100,
      timestamp: ''
    }
  },
  methods: {
    leaderticketshow (id) {
      this.leaderTicketDetailVisible = true
      this.ticketid = id
      console.log('ticketid:' + this.ticketid)
    },
    ticketdel (id) {
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'error'
      }).then(() => {
        var _this = this
        this.$http.post(`/api/ticket/remove/` + id).then(function (response) {
          if (response.data.success === true) {
            _this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            console.log('删除失败:' + response.data.message)
            _this.$message({
              message: '删除失败:' + response.data.message,
              type: 'error'
            })
          }
          _this.getTicket()
          _this.getResult()
        })
      })
    },
    beforeAvatarUpload (file) {
      console.log('文件类型')
      console.log(file.name)
      const isFormat = file.name.indexOf('.rsprj') > 0
      // const isLt5M = file.size / 1024 / 1024 < 500
      if (!isFormat) {
        this.$message.error('上传文件只能是 .rsprj 格式!')
      }
      return isFormat
    },
    // 获取用户列表
    getImportList (res) {
      if (res.success) {
        this.$message({
          message: '导入成功！' + res.message,
          type: 'success'
        })
        this.getResult()
      } else {
        console.log(res.Msg)
        this.$message({
          message: '导入失败:' + res.message,
          type: 'error'
        })
      }
      this.fileList = []
    },
    uploaderror (err) {
      console.log('具体错误')
      console.log(err)
      this.$message({
        message: '导入失败，可能是文件大小超出系统限制:' + err,
        type: 'error'
      })
    },
    leaderticket (id) {
      this.leaderTicketVisible = true
      this.ticketid = id
      this.timestamp = new Date().getTime()
      console.log('timestamp:' + this.timestamp)
    },
    importresult () {
      this.$router.push('/assess/importresult/' + this.$route.params.id)
    },
    backtolist () {
      this.$router.push('/assess')
    },
    mainheight (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - 145
      })
    },
    getDetails () {
      var _this = this
      this.$http
        .get(`/api/prj/details/` + this.$route.params.id)
        .then(function (response) {
          _this.unitcode = response.data.project.code
          _this.unitname = response.data.project.inname
          _this.leaders = response.data.leaders
          _this.leaders.forEach(element => {
            if (element.zhiwu === '正职') {
              _this.leaderszhengzhi.push(element)
            }
          })
          _this.preferments = response.data.preferments
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    getTicket () {
      var _this = this
      this.$http
        .get(`/api/ticket/list/` + this.$route.params.id)
        .then(function (response) {
          _this.ticketLeaderList = response.data
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    getResult () {
      var _this = this
      this.$http
        .get(`/api/prj/result/` + this.$route.params.id)
        .then(function (response) {
          if (response.data.ticketinfo) {
            _this.ticketinfoshow = true
            _this.tabledata = JSON.parse(response.data.ticketinfo)
            _this.kaohe = response.data.kaohe
            _this.pingyi = response.data.pingyi
          } else {
            _this.ticketinfoshow = false
          }
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    submitsuccess () {
      console.log('提交成功，返回父组建')
      this.leaderTicketVisible = false
      this.getTicket()
      this.getResult()
    }
  },
  mounted () {
    this.mainheight(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.mainheight(_this)
    }
    this.getDetails()
    this.getResult()
    this.getTicket()
  }
}
</script>
<style>
#assessdetail .el-upload-list__item{
  width: 250px;
}
#assessdetail a{
  width: 200px;
}
.assessdetail .el-tabs__header{
  height: 29px;
  background: #FAFAFA;
  line-height: 30px;
  font-family: '宋体';
  padding:0 20px;
  border-bottom: 2px solid #E4E7ED;
  margin:0;
}
.assessdetail .el-tabs__item{
  line-height: 30px;
  height: 30px;
  font-weight:bolder;
}
  .cardtab .el-tabs__header{
    padding:0 !important;
    border-bottom:1px solid #E4E7ED;
  }
  #assessdetail .wboxs{
    height:45px;
    padding-top:0;
    margin-bottom: 10px;
  }
  .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>

<style scoped>
  .tickettable th{
    font-weight:lighter;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    text-align: center;
  }
  .tickettable{
    width: 100%;
    border-left: 1px solid #95B8E7;
    border-top: 1px solid #95B8E7;
  }
  .tickettable td, .tickettable th{
    padding:5px 10px;
    margin:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体';
    border-bottom: 1px solid #95B8E7;
    border-right: 1px solid #95B8E7;
  }
  .tickettable td{
    vertical-align: middle;
    text-align: center;
    font-weight: bolder;
  }
  .mytable{
    border-top: 1px solid #74a6cc;
    border-left: 1px solid #74a6cc;
    margin:0 10px 10px;
    width: calc(100% - 20px);
  }
  .mytable th{
    padding: 10px;
    border-right: 1px solid #74a6cc;
    border-bottom: 1px solid #74a6cc;
    vertical-align: top;
    line-height: 150%;
    background: #FAFAFA;
    width:200px;
    text-align:right;
  }
  .mytable td{
    padding: 10px;
    border-right: 1px solid #74a6cc;
    border-bottom: 1px solid #74a6cc;
    vertical-align: top;
    line-height: 150%;
  }
</style>
